
package org.movee.spring.data.hugegraph.mapping;

import org.springframework.data.mapping.PersistentEntity;

import java.util.List;

public interface HugePersistentEntity<T> extends PersistentEntity<T, HugePersistentProperty> {


    default HugePersistentProperty getRequiredIdProperty() {
        HugePersistentProperty property = this.getIdProperty();
        if (property != null) {
            return property;
        } else {
            throw new IllegalStateException(String.format("Required identifier property not found for %s!",
                    this.getType()));
        }
    }

    default HugePersistentProperty getRequiredVersionProperty() {
        HugePersistentProperty property = this.getVersionProperty();
        if (property != null) {
            return property;
        } else {
            throw new IllegalStateException(String.format("Required version property not found for %s!",
                    this.getType()));
        }
    }

    default HugePersistentProperty getRequiredPersistentProperty(String name) {
        HugePersistentProperty property = this.getPersistentProperty(name);
        if (property != null) {
            return property;
        } else {
            throw new IllegalStateException(String.format("Required property %s not found for %s!", name,
                    this.getType()));
        }
    }

    HugeEntityType getEntityType();

    String getLabel();

    Object getId(final Object bean);

    HugePersistentProperty getEdgeHeadProperty();

    HugePersistentProperty getEdgeTailProperty();

    List<HugePersistentProperty> getPersistentProperties();

}
